from tortoise.fields import IntField, CharField


class TimeIntField(IntField):
    def __init__(self, pk=False, max_time=30, min_time=5, **kwargs):
        self.max_time = max_time
        self.min_time = min_time
        super().__init__(pk=pk, **kwargs)

    @property
    def constraints(self) -> dict:
        return {
            "ge": self.min_time,
            "le": self.max_time
        }


class IPCharField(CharField):
    def __init__(self, pk=False, **kwargs):
        super().__init__(pk=pk, **kwargs)
